<?php
    require_once( 'includes/common.inc.php' );
    
    Authorizer::isUserLoggedIn();
    $page = 1;
    $totalPages = 1;
    if ( isset( $_GET['page'] ) && !empty( $_GET['page'] ) )
    {
        $page = (int)$_GET['page'];
    }
    $userList     = new UserList();
    $userManager  = new UserManager();
    $smarty       = new AdvancedSmarty();

    $smarty->caching = false;
    $currentUsers = $userManager->getRangeOfUsers( $page, $totalPages );
    $usersVars = array
    (
        'page'       => $page,
        'totalPages' => $totalPages,
        'usersList'  => $userList->getUserTable( $currentUsers )  
    );
    $varArray = array
    (
        'title'          => 'Users List',
        'description'    => 'It\'s free and always will be.',
        'css'             => '/css/style.css',
        'table'           => $smarty->getView( 'users_list/user_table_row.tpl', $usersVars ),
        'page_navigation' => $smarty->getView( 'users_list/pagination.tpl', $usersVars )
    );
    $smarty->buildLayout( 'users_list.tpl', $varArray );
?>